﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using XRoute.Server.Services.Dex;
using XRoute.DataExchange;
using System.ServiceModel;

namespace XRoute.Server.Test
{
    [TestClass]
    public class DataExchangeServiceTest
    {
        ///////////////////////////////////////////////////////////////////////

        DataExchangeContainer _host;
        DuplexChannelFactory<IDataExchangeService> _channelFactory;
        IDataExchangeService _channel;
        ServiceCallback _callback;
        Context _context;


        ///////////////////////////////////////////////////////////////////////

        [TestInitialize]
        public void Initialize()
        {
            _context = new Context();
            _host = DataExchangeContainer.CreateLocal(_context);

            _callback = new ServiceCallback();
            _channelFactory = DataExchangeContainer.CreateLocalChannelFactory(_callback);

            _channel = _channelFactory.CreateChannel();
        }

        [TestCleanup]
        public void Cleanup()
        {
            if (_host != null)
                _host.Dispose();

            if (_channel != null)
                ((ICommunicationObject)_channel).Close();

            if (_channelFactory != null)
                _channelFactory.Close();
        }

        [TestMethod]
        public void TestMethod1()
        {
        }


        ///////////////////////////////////////////////////////////////////////

        class ServiceCallback : IDataExchangeServiceCallback
        {
            public void NotifyDocument(BoardContract document)
            {
            }
        }

        class Context : IDataExchangeContext
        {
        }
    }
}
